<!-- 隐私协议 -->
<template>
	<view>
		<view class="content">
			<view class="box">
				<view class="topBox">
					<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/loginIcon/img3.png"></image>
					<text>{{title}}</text>
					<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/loginIcon/img2.png"></image>
				</view>
				<rich-text class="aircle" :nodes="content" @itemclick="itemClick" :space='nbsp'></rich-text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getCopywriting
	} from '@/apis/apis.js'
	export default {
		name: "",
		data() {
			return {
				type: null,
				title: '',
				content: '',
				nbsp:'nbsp',
			}
		},
		onLoad(options) {
			this.type = options.type
			this.init()

		},
		methods: {
			init() {
				//文案类型（0：隐私政策，1：拼单规则,2:会员权益，3：会员服务协议，4创作中心文案说明）
				getCopywriting(this.type).then(res => {
					console.log(res)
					if (res.data.content) {
						// res.data.content = res.data.content.replace(/<p>/,
						// 	'<p style="word-break: break-all;">')
						// res.data.content = res.data.content.replace(/<img /,
						// 	'<img style="max-width:100%;"')
						res.data.content = res.data.content.replace(/\<p/g,
							'<p style="word-break: break-all;"')
						res.data.content = res.data.content.replace(/\<img /g,
							'<img style="max-width:100%;"')
					}
					this.title = res.data.title
					this.content = res.data.content
					uni.setNavigationBarTitle({
						title: res.data.title
					})
				})
			},
			itemClick(e) {
				if (e.detail.node.name == 'a') {
					uni.navigateTo({
						url: '/pages/outsideLink/outsideLink?url=' + encodeURIComponent(e.detail.node.attrs.href)
					})
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		position: absolute;
		top: 0;
		bottom: 0;
		width: 100%;
		background: url('https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/loginIcon/bg1.png') no-repeat;
		background-size: auto 100%;
		background-position: 0 0;
		display: flex;
		justify-content: center;
		align-items: center;

		.box {
			width: 92%;
			height: 92%;
			background: #fff;
			border-radius: 20rpx;
			overflow: hidden;
			overflow-y: visible;
			padding: 50rpx 34rpx;

			.topBox {
				width: fit-content;
				display: flex;
				align-items: center;
				margin: 0 auto 60rpx;

				&>image {
					width: 40rpx;
					height: 10rpx;
				}

				&>text {
					font-size: 34rpx;
					font-family: Source Han Sans CN;
					font-weight: 500;
					color: #91582F;
					padding: 0 12rpx;
				}
			}

			.aircle {
				font-size: 28rpx;
				font-weight: 500;
				color: #333333;
				line-height: 52rpx;
				white-space: pre-wrap
			}
		}
	}
</style>
